<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--    <link href="js/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <script src="js/jquery-1.4.2.min.js"></script>
      包括所有已编译的插件
      <script src="js/bootstrap/js/bootstrap.min.js"></script>
       -->
      <script src="js/jqueryValidate/lib/jquery.js"></script>
      <script src="js/jqueryValidate/jquery.validate.min.js"></script>
       <script src="js/jqueryValidate/localization/messages_zh.js"></script>
       <script src="js/jqueryValidate/additional-methods.js"></script>
       
<title>jQuery-validate</title>
<style>
.error{
	color:red;
}
</style>
</head>
<body>
<script>
$.validator.setDefaults({
    submitHandler: function() {
      alert("提交事件!");
    }
});
$().ready(function() {
    $("#commentForm").validate();
});
</script>
<p><a href="jqueryValidate.jsp">1、将校验规则写到控件中</a></p>
<p><a href="jqueryValidate2.jsp">2、将校验规则写到 js 代码中</a></p>
<span><font>自定义验证规则在additional-methods.js中。</font></span>

<form class="cmxform" id="commentForm" method="get" action="">
  <fieldset>
    <legend>输入您的名字，邮箱，URL，备注。</legend>
    <p>
      <label for="cname">Name (必需, 最小两个字母)</label>
      <input id="cname" name="name" minlength="2" type="text" required>
    </p>
    <p>
      <label for="cemail">E-Mail (必需)</label>
      <input id="cemail" type="email" name="email" required>
    </p>
    <p>
      <label for="curl">URL (可选)</label>
      <input id="curl" type="url" name="url">
    </p>
    <p>
      <label for="ccomment">备注 (必需)</label>
      <textarea id="ccomment" name="comment" required></textarea>
    </p>
    <p>
      <label for="str">英文字母、数字、短横线、下划线</label>
      <textarea id="str" name="str" class="string required"></textarea>
    </p>
    <p>
      <label for="idcardno">身份证号码(自定义)</label>
      <textarea id="idcardno" name="idcardno" class="idcardno"></textarea>
    </p>
    
    <p>
      <input class="submit" type="submit" value="Submit">
    </p>
  </fieldset>
</form>
</body>
</html>